package com.bdqn;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

import java.util.Iterator;

public class Jd4 {
    public static void main(String[] args) {
        SAXReader reader=new SAXReader();
        try {
            Document document=reader.read("ch02/Short/src/Student.xml");
            Element element=document.getRootElement();
            for (Iterator itStudent = element.elementIterator();itStudent.hasNext();) {
                Element elem= (Element) itStudent.next();
                System.out.println("编号:"+elem.attributeValue("id"));
                for (Iterator itstudent=elem.elementIterator();itstudent.hasNext();){
                    Element elemen= (Element) itstudent.next();
                    System.out.println(elemen.getText());
                }
                System.out.println("\n");
            }
        } catch (DocumentException e) {
            e.printStackTrace();
        }
    }
}
